package cate.game.play.skill.passive.gem;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 受击时，有 80% 获得1层不屈，5层时获得9.6%最大生命值的减免盾，抵消 79% 伤害,持续 2 回合
 */
public class 不屈PH extends PassiveHandler {

	private int 概率;
	private int buff;
	private int 层数;
	private int 护盾;

	//概率=8000&buff=？？&层数=5&护盾=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		buff = args.getInt("buff", 0);
		层数 = args.getInt("层数", 0);
		护盾 = args.getInt("护盾", 0);
	}

	@Override
	public void afterSufferOneAttack(SkillActionCtx action, long totalDamage, boolean strike) {
		int pid = skill.owner.buff.tryAddByTid(action, skill.owner, buff, 概率);
		if (pid <= 0) {
			return;
		}
		if (skill.owner.buff.countBuffByTid(buff) >= 层数) {
			skill.owner.buff.tryAddByTid(action, 护盾);
			skill.owner.buff.removeBuffByTid(action, buff);
		}
	}
}
